﻿using SqlSugar;
using Zhp.Entity.Sys;
using Zhp.SqlSugar.Trigger;
using Zhp.SqlSugar.Trigger.Core;

namespace Zhp.Trigger.Service
{
    [Trigger(nameof(SysUser))]
    public sealed class SysUserTrigger : BaseTriggerService<SysUser, long>
    {
        public override async Task DeletedAsync(ISqlSugarClient context, SysUser entity)
        {
            await context.Deleteable<SysUserRole>(x => x.UserId == entity.Id).IsLogic().ExecuteCommandAsync();
            await context.Deleteable<SysUserMenu>(x => x.UserId == entity.Id).IsLogic().ExecuteCommandAsync();
        }
    }
}